import Vue from 'vue';
import Router from 'vue-router';

const _import = require('./_import_' + process.env.NODE_ENV);
import Full1 from '@/containers/Full1'


// Views-Pages
import Page404 from '@/views/errorPages/Page404'

/*login*/
const Login = _import('login/index');
Vue.use(Router);

export const constantRouterMap = [
    {path: '/login', component: Login, hidden: true},
    {
        path: '/pages', redirect: '/pages/p404', name: 'Pages',
        component: {
            render(c) {
                return c('router-view')
            }
        },
        children: [
            {path: '404', name: 'Page404', component: _import('errorPages/Page404')},
        ]
    }
]

export default new Router({
    mode: 'hash',
    linkActiveClass: 'open active',     //激活路由添加类
    scrollBehavior: () => ({y: 0}),
    routes: constantRouterMap
});

export const asyncRouterMap = [
    {
        path: '/', redirect: '/home', name: '首页', component: Full1, hidden: false,
        children: [
            {path: '/home', name: '首页', icon: 'android-home', component: _import('home')},
            {path: '/ranking', name: '排行榜', icon: 'connection-bars', component: _import('ranking')},
            {path: '/trend', name: '个人及趋势', icon: "ios-pulse-strong", component: _import('trend')},
            {path: '/components', name: 'component组件', redirect: '/components/alert', icon: 'bookmark',
                component: {render(c) {return c('router-view')}},
                children: [
                    {path: 'datepicker', name: 'DatePicker', icon: 'ios-calendar-outline', component: _import('components/DatePicker')},
                    {path: 'form', name: 'Form表单', icon: 'ios-list-outline', component: _import('components/Form')},
                    {path: 'modal', name: 'Modal对话框', icon: 'ios-chatbubble-outline', component: _import('components/Modal')},
                    {path: 'select', name: 'Select选择器', icon: 'ios-arrow-down', component: _import('components/Select')},
                    {path: 'spin', name: 'Spin加载中', icon: 'load-d ', component: _import('components/Spin')},
                    {path: 'upload', name: 'Upload上传', icon: 'ios-cloud-upload-outline', component: _import('components/Upload')},
                ]
            },
        ]
    },
    {path: '*', redirect: '/pages/404', hidden: true}
];
